var t = getApp();

Component({
    properties: {
        max_count: {
            value: 100,
            type: Number
        },
        customStyle: {
            value: "",
            type: String
        },
        customImgStyle: {
            value: "",
            type: String
        },
        customIconStyle: {
            value: "",
            type: String
        },
        customBoxStyle: {
            value: "",
            type: String
        },
        isSlot: {
            value: !1,
            type: Boolean
        },
        fileSrc: {
            value: "",
            type: [ String, Array ]
        }
    },
    data: {
        fileList1: [],
        fileImg: []
    },
    observers: {
        fileSrc: function(t, e) {
            "" == t || Array.isArray(t) ? "" != t && Array.isArray(t) && (console.log(t), this.setData({
                fileList1: t
            })) : this.setData({
                fileList1: [ t ]
            });
        }
    },
    created: function() {
        console.log(this, this.slot);
    },
    methods: {
        updateImages: function() {
            this.triggerEvent("updateImages", this.data.fileList1);
        },
        preview: function(t) {
            var e = t.currentTarget.dataset.src;
            wx.previewImage({
                current: this.data.fileList1[e],
                urls: this.data.fileList1
            });
        },
        delIntu_1: function(t) {
            var e = t.currentTarget.id, i = this.data.fileList1.splice(e, 1);
            this.setData({
                fileList1: this.data.fileList1,
                fileImg: this.data.fileImg.splice(e, 1)
            }), this.triggerEvent("delete", {
                url: i,
                index: e
            }), this.updateImages(), this.triggerEvent("inputimg", this.data.fileImg);
        },
        onRead_1: function() {
            var t = this;
            wx.chooseImage({
                count: this.data.max_count - this.data.fileList1.length,
                sizeType: [ "original", "compressed" ],
                sourceType: [ "album", "camera" ],
                success: function(e) {
                    t.triggerEvent("beforeUp", e.tempFilePaths), t.unload({
                        tempFilePaths: e.tempFilePaths
                    }, "1");
                }
            });
        },
        unload: function(e, i) {
            var a = t.getNetAddresss("upload.uploadPic"), s = this, l = e.i ? e.i : 0, r = e.success ? e.success : 0, n = e.fail ? e.fail : 0;
            wx.showLoading({
                title: "正在上传"
            }), wx.uploadFile({
                url: a,
                filePath: e.tempFilePaths[l],
                name: "file",
                formData: null,
                success: function(t) {
                    var e = JSON.parse(t.data);
                    "1" == i && (s.data.fileList1.push(e.data.img_url), s.setData({
                        fileList1: s.data.fileList1
                    }), s.triggerEvent("successUp", {
                        res: e,
                        list: s.data.fileList1
                    }), s.updateImages(), s.data.fileImg.push(e.data.img), s.triggerEvent("inputimg", s.data.fileImg));
                },
                fail: function(t) {
                    n++;
                },
                complete: function(t) {
                    wx.hideLoading(), ++l == e.tempFilePaths.length ? (console.log("执行完毕"), console.log("成功：" + r + " 失败：" + n)) : (e.i = l, 
                    e.success = r, e.fail = n, s.unload(e, i));
                }
            });
        }
    }
});